package com.example.myapp;

import androidx.appcompat.app.AppCompatActivity;

import android.os.Bundle;
import android.view.MotionEvent;
import android.view.View;
import android.widget.FrameLayout;

import com.example.view.MoveView;

public class MainActivity extends AppCompatActivity {

    @Override
    protected void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);
        setContentView(R.layout.activity_main);
        FrameLayout frameLayout = (FrameLayout) findViewById(R.id.myLayout);
        final MoveView moveView = new MoveView(MainActivity.this);

        moveView.setOnTouchListener(new View.OnTouchListener() {
            @Override
            public boolean onTouch(View v, MotionEvent event) {
                moveView.bitmapX = event.getX()-150;
                moveView.bitmapY = event.getY()-150;
                moveView.invalidate();
                return true;
            }
        });
        frameLayout.addView(moveView);
    }
}
